package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	inputFile, inputError := os.Open("E:\\Go_Project\\GO_LEARN\\Day01\\break\\main\\main.go")
	if inputError != nil {
		fmt.Printf("An error occurred on opening the inputfile\n" +
			"Does the file exist?\n" +
			"Have you got acces to it?\n")
		return //退出程序
	}
	//defer 如果成功打开文件 确保在程序结束时能关闭文件
	defer inputFile.Close()

	inputReader := bufio.NewReader(inputFile)
	for {
		inputString, readerError := inputReader.ReadString('\n')
		if readerError != nil {
			return
		}
		fmt.Printf("The input was: %s", inputString)
	}

}
